package com.spring.test.pattern.observer;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
// ====== 在Spring中使用事件监听机制(事件、监听、发布)
// ====== 监听类,在spring配置文件中,注册事件类和监听类
public class ApplicationContextListenerOne implements ApplicationListener<ApplicationEvent> {
	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof MessageSourceEvent) {
			System.out.println("进入到监听器类---one");
			MessageSourceEvent myEvent = (MessageSourceEvent) event;
			myEvent.print();
		}
	}
}
